import request from "@/apps/admin/units/request"
import {HttpResultData, HttpResultPaging, HttpResult} from "@/types/project";

export const POWER: any = {
    LIST:"administer.user.list",//查看管理
    CREATED:"administer.user.created",//创建添加
    UPDATED:"administer.user.updated",//编辑修改
    CODE:"administer.user.code",//创建授权码
    LOCKING:"administer.user.locking",//锁定账号
    UNLOCK:"administer.user.unlock",//解锁账号
    OFFLINE:"administer.user.offline",//强制下线
    REMOVE:"administer.user.remove"//删除账号
}


/**
 * api
 * 获取管理员
 */
export const getUserListApi = (where: any): Promise<HttpResultPaging<any>> => request(`/administer-user/list`, where)

/**
 * 创建会员接口
 */
export const createdUserApi: string = `/administer-user/created`;

/**
 * 编辑会员接口
 */
export const updatedUserApi: string = `/administer-user/updated`;

/**
 * 删除会员接口
 * @param id
 */
export const removeUserApi = (id:number): Promise<HttpResultData<any>> => request(`/administer-user/remove`, {id},'POST')

/**
 * 创建授权码接口
 * @param id
 */
export const createdCodeApi = (id: number): Promise<HttpResultData<string>> => request(`/administer-user/created-code`, {id},'POST')

/**
 * 修改会员状态
 * @param id
 * @param status
 */
export const changeStatusApi = (id: number | number[], status: 0 | 1): Promise<HttpResultPaging<string>> => request(`/administer-user/status`, {id, status}, 'POST')

/**
 * 锁定账号
 * @param id
 */
export const lockingAccountApi = (id: number | number[]): Promise<HttpResult> => request(`/administer-user/locking`, {id},'POST')

/**
 * 解除锁定账号
 * @param id
 */
export const unlockAccountApi = (id: number | number[]): Promise<HttpResult> => request(`/administer-user/unlock`, {id},'POST')

/**
 * 解除锁定账号
 * @param user_id
 */
export const onlineListApi = (user_id: number): Promise<HttpResult> => request(`/administer-user/online-list`, {user_id})

/**
 * 解除锁定账号
 * @param fd
 */
export const forcedOfflineApi = (fd: number | string): Promise<HttpResult> => request(`/administer-user/offline`, {fd})
